import importlib

# 获取所有命令行的内容
command_module_list = [
    "command_line.expand",
    "command_line.show",
    "command_line.basic"
]

if __name__ == "__main__":
    print("Hello coder,You can stop me by typing 'stop'", end="\n")

    # 主程序循环
    while True:
        command = input(">>>")

        # 结束判断
        if command == "stop":
            break

        # 搜索查询输入的命令
        break_flag = False
        for this_module in command_module_list:

            # 加载列表中的模块
            cli = importlib.import_module(this_module)
            this_cmd = cli.my_cmd

            # 遍历模块中的索引
            for cmd_key in this_cmd:
                if cmd_key == command:
                    print("Description: " + this_cmd[cmd_key])
                    break_flag = True
                    break

            # 查询到内容，停止导入索引包
            if break_flag:
                print("Module stops importing")
                break

        # 提示是否查询到命令
        if not break_flag:
            print("Command line not found")
